home *** CD-ROM | disk | FTP | other *** search
- Path: harden.demon.co.uk!mark
- From: Mark Harden <mark@harden.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Array of pointers to a tree structure ?
- Date: Wed, 10 Jan 1996 12:16:53 +0000
- Organization: Not an organisation
- Distribution: world
- Message-ID: <nxRvQDA1468wEw$$@harden.demon.co.uk>
- References: <4d067t$9lc@hermes.fundp.ac.be>
- NNTP-Posting-Host: harden.demon.co.uk
- X-NNTP-Posting-Host: harden.demon.co.uk
- MIME-Version: 1.0
- X-Newsreader: Turnpike Version 1.10 <RMdKwNiDEBO6d87vIffee+0s$n>
-
- In article <4d067t$9lc@hermes.fundp.ac.be>, Francisco Melo Ledermann
- <fmelo@biq.fundp.ac.be> writes
- >Hi Colleagues, I have been learning C language just from one month ago
- >and I don't know too much about this language. I have a problem with the
- >assignment of pointers in an array of pointers with a specifical defined
- >structure. For example:
- >
- >
- >/* BOXES STRUCTURE FOR THE CONSTRUCTION OF A TREE */
- >
- >struct boxes {
- > int number;
- > struct boxes *pointer_1;
- > struct boxes *pointer_2;
- > struct boxes *pointer_3;
- > }
- >
- >/* ARRAY OF POINTERS TO BOXES STRUCTURE FOR MANAGE */
- >/* SOME BRANCHES OF THE TREE */
- >
- >struct boxes array_pointers [15];
-
- Should be "strut boxes *array_pointers [15];" otherwise you are defining
- an array of structures.
-
- >Supose that I have the array of pointers already defined, with every
- >pointer pointing to a boxes structure and every boxes structure
- >contains only the integer number defined. In this moment I would like
- >to define the three pointers in every box in the way of these pointers
- >point to another element in the array. I have tried statements like
- >this with out success:
-
- This is quite advanced stuff.
-
- I do not quite understand what you want to do. The pointers defined in
- the structure are defined to pint to the structure itself NOT the array
- or an element of it.
-
- To set "number" in the structure pointed to by array element 3 to 13 you
- would :-
-
- *array_pointers [3]->number = 13;
-
- To set "pointer_1" in the structure pointed to be array element 3 to
- that pointed to by array element 4 you would :-
-
- *array_pointers [3]->pointer_1 = array_pointers [4];
-
- I hope this helps. If not please give more details. It is also worth
- looking at the FAQ as it deals quite well with pointers and arrays.
-
-
- > Francisco Melo Ledermann
- >
- >mailto:fmelo@biq.fundp.ac.be
- >
- >http://biq-pc1.biq.fundp.ac.be/index.html
-
- --
- Mark Harden
-